﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="edit.aspx.cs" Inherits="QualityRPT.CARDContract.edit" %>

<%@ Register TagPrefix="uc1" TagName="clheader" Src="../include/cl_header.ascx" %>
<%@ Register TagPrefix="uc1" TagName="cltop" Src="../include/cl_top.ascx" %>
<%@ Register TagPrefix="uc1" TagName="clleft" Src="../include/cl_left.ascx" %>
<%@ Register TagPrefix="uc1" TagName="clfooter" Src="../include/cl_footer.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>ETC产品质量跟踪统计系统-编辑IC卡合同信息</title>
    <uc1:clheader ID="clheader" runat="server" />
    <link rel="stylesheet" href="../css/jquery.combobox.css" />
	<script type="text/javascript" src="../js/jquery.bgiframe.pack.js"></script>
	<script type="text/javascript" src="../js/jquery.combobox.js"></script>
	<script type="text/javascript">
		$(function () {
		    $('#txt_supplier_name').combobox([<%=supplier_name_json %>], { imageUrl: '/img/dropdown.gif' });
            $('#txt_spec_name').combobox([<%=spec_name_json %>], { imageUrl: '/img/dropdown.gif' });
            $('#txt_spec_shortname').combobox([<%=spec_shortname_json %>], { imageUrl: '/img/dropdown.gif' });
            //txt_contract_no change
            $("#txt_contract_no").change(function () {
               if($("#h_rowid").val().length==0 && $("#h_rowid").val().length==0)
               {
                    var params = "&st=y&spin=" + spin; var ajaxurl = "/include/api.aspx";
                    $.ajax({type: 'POST', url: ajaxurl, data: "action=getmulsclist" + params + "&nocache=" + Math.random(), dataType: 'json',success: function (ret) {
                            if (ret.responseStatus == 200)//right
                            {
                                window.location.href="edit.aspx?cnno="+$("#txt_contract_no").val()+"&pid="+getUrlParam('pid')+"&cid="+getUrlParam('cid');       
                            } 
                        }
                    });
                }
            });
            //text_end_no change
            $("#txt_endno").change(function () {
                if($("#txt_spec_name").val().length==0||$("#txt_spec_shortname").val().length==0||$("#txt_softversion").val().length==0
                    ||$("#txt_hardversion").val().length==0||$("#txt_keyversion").val().length==0
                    ||$("#txt_startno").val().length==0||$("#txt_endno").val().length==0){
                        alert('请检查上面的必填项是否填写完整');return; }
                    $("#range_table_div").show();
                    var dev_cnt = $("#txt_endno").val() - $("#txt_startno").val();
                    $tr = $("<tr>" + "<td><input name='spec_name' type='hidden' value='" + $("#txt_spec_name").val() + "'/>" + $("#txt_spec_name").val() + "</td>"
                                   + "<td><input name='spec_shortname' type='hidden' value='" + $("#txt_spec_shortname").val() + "'/>" + $("#txt_spec_shortname").val() + "</td>"
                                   + "<td><input name='soft_version' type='hidden' value='" + $("#txt_softversion").val() + "'/>" + $("#txt_softversion").val() + "</td>"
                                   + "<td><input name='hard_version' type='hidden' value='" + $("#txt_hardversion").val() + "'/>" + $("#txt_hardversion").val() + "</td>"
                                   + "<td><input name='key_version' type='hidden' value='" + $("#txt_keyversion").val() + "'/>" + $("#txt_keyversion").val() + "</td>"
                                   + "<td><input name='start_no' type='hidden' value='" + $("#txt_startno").val() + "'/>" + $("#txt_startno").val() + "</td>"
                                   + "<td><input name='end_no' type='hidden' value='" + $("#txt_endno").val() + "'/>" + $("#txt_endno").val() + "</td>"
                                   + "<td><input name='device_count' type='hidden' value='" + dev_cnt + "'/>" + dev_cnt + "</td>"
                                   + "<td><a href='#' onclick='$(this).parent().parent().remove();sumdevcnt();'>删除</a></td></tr>");
                    $("#range_table").append($tr); sumdevcnt();$(".tbcl").val("");
            });
            sumdevcnt();//加载后计算一下设备数量
		});
        var device_sumcnt = 0;
        function sumdevcnt(){
            $("input[name='device_count']").each(function(){device_sumcnt += Number($(this).val());}); 
            $("#txt_device_count").val(device_sumcnt);
        }
        function checkSubmit()
        {
            if($("#txt_contract_no").val().length==0||$("#txt_supplier_shortname").val().length==0
                ||device_sumcnt==0||$("#txt_net_no").val().length==0)
            {
                alert("请检查必填项.");return false;
            }
            return true;
        }
	</script>
</head>
<!-- this is content start-->
<body>
    <uc1:cltop ID="cltop" runat="server" />
    <div class="container-fluid">
    <div class="row-fluid">
        <uc1:clleft id="clleft" runat="server"/>
         <!-- this is content start-->
        <form id="Form1" runat="server">
         <div class="box span10">
			<div class="box-header well">
				<h2><i class="icon-edit"></i>IC卡合同信息--------<a href='index.aspx?pid=<%=Request.Params["pid"] %>&cid=<%=Request.Params["cid"] %>'>返回</a></h2>
			</div>
            <div class="box-content" style=" float:left">
                <div style="clear:both;height:12px;"></div>
                <asp:Label ID="Label1" runat="server" Text="合同编号："></asp:Label>
                <input type="text" id="txt_contract_no" runat="server" /><span style="color:Red;">必填</span>
                <asp:Label ID="Label2" runat="server" Text="合同名称："></asp:Label>
                <input type="text" id="txt_contract_name" runat="server" /><span style="color:Gray;">可空</span>
                <div style="clear:both;height:12px;"></div>
                <asp:Label ID="Label3" runat="server" Text="签订日期："></asp:Label>
                <input type="text" id="txt_sign_date" runat="server" class="datepicker" /><span style="color:Gray;">可空</span>
                <asp:Label ID="Label4" runat="server" Text="标签厂商："></asp:Label>
                <input type="text" id="txt_supplier_name" class="combo" runat="server" /><span style="color:Red;">必填</span>
                <div style="clear:both;height:12px;"></div>
                <asp:Label ID="Label5" runat="server" Text="厂商编号："></asp:Label>
                <input type="text" id="txt_supplier_shortname" runat="server" /><span style="color:Gray;">可空</span>
                <asp:Label ID="Label6" runat="server" Text="型号名称："></asp:Label>
                <input type="text" id="txt_spec_name" runat="server" class="tbcl" /><span style="color:Red;">必填</span>
                <div style="clear:both;height:12px;"></div>
                <asp:Label ID="Label7" runat="server" Text="型号简称："></asp:Label>
                <input type="text" id="txt_spec_shortname" runat="server" class="tbcl" /><span style="color:Gray;">可空</span>
                <asp:Label ID="Label8" runat="server" Text="软件版本："></asp:Label>
                <input type="text" id="txt_softversion" runat="server" class="tbcl" /><span style="color:Red;">必填</span>
                <div style="clear:both;height:12px;"></div>
                <asp:Label ID="Label9" runat="server" Text="硬件版本："></asp:Label>
                <input type="text" id="txt_hardversion" runat="server" class="tbcl" /><span style="color:Red;">必填</span>
                <asp:Label ID="Label10" runat="server" Text="密钥版本："></asp:Label>
                <input type="text" id="txt_keyversion" runat="server" class="tbcl" /><span style="color:Red;">必填</span>
                <div style="clear:both;height:12px;"></div>
                <asp:Label ID="Label11" runat="server" Text="开始号段："></asp:Label>
                <input type="text" id="txt_startno" runat="server" class="tbcl" /><span style="color:Red;">必填</span>
                <asp:Label ID="Label12" runat="server" Text="结束号段："></asp:Label>
                <input type="text" id="txt_endno" runat="server" class="tbcl" /><span style="color:Red;">必填</span>
                <div style="clear:both;height:12px;"></div>
                <div id="range_table_div" runat="server">
                    <table id="range_table" class="table table-bordered">
                        <tr>
                            <th>型号名称</th>
                            <th>型号简称</th>
                            <th>软件版本</th>
                            <th>硬件版本</th>
                            <th>密钥版本</th>
                            <th>标签开始号</th>
                            <th>标签结束号</th>
                            <th>数量</th>
                            <th>操作</th>
                        </tr>
                        <asp:Repeater runat="server" ID="repeater_num_range">
                        <ItemTemplate>
                            <tr>
                                <td><input type="hidden" name="spec_name" value='<%# DataBinder.Eval(Container.DataItem, "SPEC_NAME")%>' /><%# DataBinder.Eval(Container.DataItem, "SPEC_NAME")%></td>
                                <td><input type="hidden" name="spec_shortname" value='<%#QualityRPT.AppTools.GetSpecShortName(DataBinder.Eval(Container.DataItem, "SPEC_NAME"))%>' /><%#QualityRPT.AppTools.GetSpecShortName(DataBinder.Eval(Container.DataItem, "SPEC_NAME"))%></td>
                                <td><input type="hidden" name="soft_version" value='<%# DataBinder.Eval(Container.DataItem, "SOFT_VERSION")%>' /><%# DataBinder.Eval(Container.DataItem, "SOFT_VERSION")%></td>
                                <td><input type="hidden" name="hard_version" value='<%# DataBinder.Eval(Container.DataItem, "HARD_VERSION")%>' /><%# DataBinder.Eval(Container.DataItem, "HARD_VERSION")%></td>
                                <td><input type="hidden" name="key_version" value='<%# DataBinder.Eval(Container.DataItem, "KEY_VERSION")%>' /><%# DataBinder.Eval(Container.DataItem, "KEY_VERSION")%></td>
                                <td><input type="hidden" name="start_no" value='<%# DataBinder.Eval(Container.DataItem, "START_NO")%>' /><%# DataBinder.Eval(Container.DataItem, "START_NO")%></td>
                                <td><input type="hidden" name="end_no" value='<%# DataBinder.Eval(Container.DataItem, "END_NO")%>' /><%# DataBinder.Eval(Container.DataItem, "END_NO")%></td>
                                <td><input type="hidden" name="device_count" value='<%# DataBinder.Eval(Container.DataItem, "DEVICE_COUNT")%>' /><%# DataBinder.Eval(Container.DataItem, "DEVICE_COUNT")%></td>
                                <td><a href='#' onclick='$(this).parent().parent().remove();'>删除</a></td>
                            </tr>
                        </ItemTemplate>
                        </asp:Repeater>
                    </table>
                </div>
                <div style="clear:both;height:12px;"></div>
                <asp:Label ID="Label13" runat="server" Text="设备数量："></asp:Label>
                <input type="text" id="txt_device_count" runat="server" readonly="readonly" /><span style="color:Gray;">计算</span>
                <asp:Label ID="Label14" runat="server" Text="IC卡容量："></asp:Label>
                <asp:TextBox ID="txt_card_ram" runat="server" /><span style="color:Gray;">可空</span>
                <div style="clear:both;height:12px;"></div>
                <asp:Label ID="Label17" runat="server" Text="网络编号："></asp:Label>
                <input type="text" id="txt_net_no" runat="server" /><span style="color:Gray;">必填</span>
                <asp:Label ID="Label18" runat="server" Text="到验日期："></asp:Label>
                <input type="text" id="txt_created_date" runat="server" class="datepicker" /><span style="color:Gray;">可空</span>
                <div style="clear:both;height:12px;"></div>
                &nbsp;&nbsp;&nbsp;&nbsp;<asp:Label ID="Label19" runat="server" Text=" 备注："></asp:Label>
                <input type="text" id="txt_remark" runat="server" /><span style="color:Gray;">可空</span>
                <div style="clear:both;height:12px;"></div>
                <asp:Button ID="ButtonSave" runat="server" Text="保存" CssClass="botton" OnClientClick="return checkSubmit();" OnClick="ButtonSave_Click" />
                <asp:Button ID="ButtonContinue" runat="server" Text="保存并继续" CssClass="botton" OnClientClick="return checkSubmit();" OnClick="ButtonContinue_Click" />
                <input type="hidden" id="h_contract_no" runat="server" />
                <div style="clear:both;height:12px;"></div>
            </div>
         </div>
         </form>
        
        </div>		
        <!-- content end-->
    </div>
    <uc1:clfooter ID="clfooter" runat="server" />
</body>
</html>
